/**
 * Created by zhang on 4/28/2017.
 */

var fs = require('fs');
var iconv = require('C:\\Users\\zhang\\Documents\\env\\node-v6.10.2-win-x64\\node_modules\\iconv-lite');

/**
 * read file content and delete BOM
 */
/*function readText(filePath) {

    var bin = fs.readFileSync(filePath);

    if (bin[0] === 0xEF && bin[1] === 0xBB && bin[2] === 0xBF){
        bin = bin.slice(3);
    }

    return bin.toString('utf-8');
}

console.log(readText('C:\\Users\\zhang\\Documents\\开发文档\\定标\\html-docs\\index.html'));*/

/**
 * read GBK file
 */
function readGBKText(filePath) {
    return iconv.decode(fs.readFileSync(filePath), 'gbk');
}

console.log(readGBKText('C:\\Users\\zhang\\Documents\\开发文档\\定标\\html-docs\\index.html'));